#include "login.h"
#include "ui_login.h"
#include <QMovie>
#include<QLabel>
#include <QMouseEvent>

login::login(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::login),
    m_label(new QLabel)

{
    ui->setupUi(this);
    //去除边框
    this->setWindowFlags(Qt::FramelessWindowHint);
    //labtop设置动画
    QMovie* movie = new QMovie(this); //播放gif
    movie->setFileName((":/img/jianbian.gif"));
    movie->start();//播放
    ui->labtop->setMovie(movie);

    //username提示
    ui->username->lineEdit()->setPlaceholderText("账号/手机");

    //设置头像
    ui->labprotrait->setMask(QRegion(ui->labprotrait->rect(),QRegion::RegionType::Ellipse));
}

login::~login()
{
    delete ui;
}

void login::mouseMoveEvent(QMouseEvent *event)
{
    if(mouse_press){
           move(event->globalPos() - mousePoint);
   //        event->accept();
       }

}

void login::mousePressEvent(QMouseEvent *event)
{
    if( (event->button() == Qt::LeftButton) ){
           mouse_press = true;
           mousePoint = event->globalPos() - this->pos();
   //        event->accept();
       }
      /* else if(event->button() == Qt::RightButton){
           //如果是右键
           this->close();

       }*/

}

void login::mouseReleaseEvent(QMouseEvent *event)
{
     mouse_press = false;
}

void login::on_minButton_clicked()
{
    //最小化窗口
    this->showMinimized();
}

void login::on_closeButton_clicked()
{
    //关闭窗口
    this->close();
}

void login::on_loginButton_released()
{
    //关闭当前窗口
    this->close();

    Qtproject *qtproject = new Qtproject;
    qtproject->show();
}


